<template>
  <LoginBox>
    <div class="login">
      <div class="logo">
        <img src="@/assets/logo1.png" />
      </div>

      <div class="input-box">
        <div style="margin-top: 30px">
          <label>邮箱</label>
          <MyInput
            label="邮箱地址"
            width="250"
            type="email"
            placeholder="请输入邮箱地址"
            v-model="entity.email"
          />
        </div>
        <div style="margin-top: 40px">
          <label>验证码</label>
          <MyInput
            label="验证码"
            width="150"
            v-model="entity.vcode"
            placeholder="请输入验证码"
          />
          <button
            class="send-msg"
            @click="send(entity.email)"
            :disabled="isCooing"
            :class="{ 'disabled-c': isCooing }"
          >
            {{ msg }}
          </button>
        </div>

        <div style="margin-top: 50px; text-align: center">
          <CButton @click="login(entity)"> 登录 </CButton>
        </div>
        <div style="text-align: center; margin-top: 60px">
        
          <span class="scan-code-login-btn" @click="toQrcodeLogin">扫码登陆</span>
        </div>
      </div>
    </div>
  </LoginBox>
</template>

<script lang='ts'>
import { defineComponent  } from "vue";
import { useRouter } from 'vue-router'

import { useUserEmailLogin, useUserEmailSender } from "@/hooks";

import LoginBox from "@/components/LoginBox.vue";
import MyInput from "@/components/MyInput.vue";
import CButton from "@/components/CButton.vue";

export default defineComponent({
  name: "login",
  components: {
    LoginBox,
    MyInput,
    CButton,
  },
  setup(props, context) {
    const router = useRouter();

    const toQrcodeLogin = function(){
      router.push({name:'qr-login'})
    };

    return {
      toQrcodeLogin,
      ...useUserEmailLogin(),
      ...useUserEmailSender(),
    };
  },
});
</script>

<style lang='less' scoped>
.login {
  user-select: none;
  text-align: center;
  padding: 15px;
  .logo {
    padding-top: 60px;
    img {
      width: 200px;
    }
  }

  .scan-code-login-btn {
    color: #313131bd;
    cursor: pointer;
    &:hover {
      color: #fff;
    }
  }

  .input-box {
    padding: 30px;
    font-size: 16px;
    font-weight: 500;
    font-family: Verdana, Geneva, Tahoma, sans-serif;
    width: 100%;
    text-shadow: 0 0 1px rgba(0, 0, 0, 0.2);
    .send-msg {
      width: 80px;
      margin-left: 15px;
      font-size: 12px;
      border: 1px solid #000;
      background-color: #000;
      color: #fff;
      border-radius: 3px;
      padding: 3px 6px;
      outline: none;
      cursor: pointer;
    }
  }
}

.disabled-c {
  cursor: no-drop !important;
  background-color: rgb(233, 230, 230) !important;
  color: rgb(104, 104, 104) !important;
  border-color: rgb(83, 82, 82) !important;
}
</style>